<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="../layui/css/layui.css" media="all">
    <title>医生注册</title>
</head>

<body>
    <!--导航栏-->
    <div class="layui-row" style="background-color:#393D49">
        <div class="layui-col-md2">
            <p style="font-size:25px;font-weight:600;color:#fff;margin-top:16px;margin-left: 80px;">MCMS</p>
        </div>
        <div class="layui-col-md10">
            <ul class="layui-nav" lay-filter="">
                <li class="layui-nav-item "><a href="../index.html">首页</a></li>
                <li class="layui-nav-item layui-this"><a href="">帮助</a></li>
            </ul>
        </div>
    </div>



    <!--注册信息-->
    <div style="margin: 0 auto; width: 600px;margin-top: 60px;">
        <div style="margin-left:39px;">
            <p style="font-size:20px;font-weight:600;">患者注册</p>
        </div>
        <form class="layui-form" action="/patient/patientinformation.html">
            <div class="layui-form-item" style="margin-top:30px;">
                <label class="layui-form-label">患者姓名</label>
                <div class="layui-input-block">
                    <input type="text" name="pname" lay-verify="pname" autocomplete="off" placeholder="请输入真实姓名" class="layui-input"
                        style="width: 400px;">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">患者性别</label>
                <div class="layui-input-block">
                    <input type="radio" name="psex" value="男" title="男" checked>
                    <input type="radio" name="psex" value="女" title="女">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">出生年月</label>
                <div class="layui-input-inline">
                    <input type="text" name="pdate" id="date" lay-verify="date" placeholder="年-月-日" autocomplete="off"
                        class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">身份证号</label>
                <div class="layui-input-block">
                    <input type="text" name="pidentity" lay-verify="identity" placeholder="请输入身份证号" autocomplete="off"
                        class="layui-input" style="width: 400px;">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">联系方式</label>
                <div class="layui-input-inline">
                    <input type="tel" name="connection" lay-verify="required|phone" autocomplete="off" placeholder="请输入手机号"
                        class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">家庭住址</label>
                <div class="layui-input-block">
                    <input type="text" name="address" lay-verify="address" autocomplete="off" placeholder="请输入家庭地址"
                        class="layui-input" style="width: 400px;">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" type="button" lay-submit lay-filter="put">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>

    <script src="../layui/layui.js" charset="utf-8"></script>
    <script src="../js/jquery-3.3.1.js"></script>

    <!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->

    <script>
        //注意：导航 依赖 element 模块，否则无法进行功能性操作
        layui.use('element', function () {
            var element = layui.element;

            //…
        });
    </script>
    <script>
        layui.use(['form', 'layedit', 'laydate'], function () {
            var form = layui.form,
                layer = layui.layer,
                layedit = layui.layedit,
                laydate = layui.laydate;

            //日期
            laydate.render({
                elem: '#date'
            });
            laydate.render({
                elem: '#date1'
            });

            //创建一个编辑器
            var editIndex = layedit.build('LAY_demo_editor');

            //自定义验证规则
            form.verify({
                pname: function (value) {
                    if (value.length < 1) {
                        return '请输入姓名';
                    }
                },
                address: function (value) {
                    if (value.length < 1) {
                        return '请输入家庭地址'
                    }
                },
                pass: [/(.+){6,12}$/, '密码必须6到12位'],
                content: function (value) {
                    layedit.sync(editIndex);
                }
            });

            //监听提交
            form.on('submit(put)', function (data) {
                console.log(1);
                $.ajax({
                    url: '/ajax/patientLogin',
                    type: 'post',
                    data: $(data.form).serialize(),
                    //  contentType:"application/json",
                    success: function (info) {
                        window.alert("success");
                        window.location.replace("/patient/patientinformation.html") ;

                    },
                    error:function () {
                        window.alert("1");
                    }
                });

                // layer.alert(JSON.stringify(data.field), {
                //     title: '最终的提交信息'
                // });

                return false;
            });

            //表单初始赋值
            // form.val('example', {
            //     "username": "贤心" // "name": "value"
            //         ,
            //     "password": "123456",
            //     "interest": 1,
            //     "like[write]": true //复选框选中状态
            //         ,
            //     "close": true //开关状态
            //         ,
            //     "sex": "女",
            //     "desc": "我爱 layui"
            // })


        });
    </script>
</body>

</html>
